package com.jack.charging.device.controller;

import com.jack.charging.common.pojo.JsonResult;
import com.jack.charging.common.pojo.param.GunStatusUpdateParam;
import com.jack.charging.common.pojo.vo.StationInfoVO;
import com.jack.charging.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Jack
 * @date 2025/2/10 12:49
 * @see
 * @since
 */
@Slf4j
@RestController
@RequestMapping("/device")
@Api(tags = "设备模块")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    @ApiOperation(value = "获取充电站信息")
    @GetMapping(value = "/station/info/{gunId}")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable("gunId")Integer gunId){
        log.debug("获取充电站信息-deviceService:入参:{}", gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfo(gunId);
        log.debug("获取充电站信息-deviceService:出参:{}", stationInfoVO);
        return JsonResult.ok(stationInfoVO, "获取充电站信息成功");
    }

    @ApiOperation(value = "更新枪状态")
    @PostMapping(value = "/station/gun/status/update")
    public JsonResult<Boolean> updateGunStatus(@RequestBody GunStatusUpdateParam param){
        log.debug("更新枪状态-deviceService:入参:{}", param);
        Boolean result = deviceService.updateGunStatus(param);
        log.debug("更新枪状态-deviceService:出参:{}", result);
        return JsonResult.ok(result, "更新枪状态成功");
    }
}
